//
//  YHBZDCell.m
//  HBDemo
//
//  Created by RYX on 2019/3/25.
//  Copyright © 2019 tuobu. All rights reserved.
//

#import "YHBZDCell.h"
#import "YHBZDSNModel.h"

@interface YHBZDCell ()

@property (nonatomic,weak) UILabel *la1;
@property (nonatomic,weak) UILabel *la2;
@property (nonatomic,weak) UILabel *la3;
@property (nonatomic,weak) UILabel *la4;

@end

@implementation YHBZDCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setUI];
    }
    
    return self;
}

- (void)setUI{
    
    UILabel *la1 = [[UILabel alloc] init];
    la1.textColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0];
    la1.textAlignment = NSTextAlignmentCenter;
    la1.text = @"--";
    la1.font = [UIFont systemFontOfSize:10];
    [self addSubview:la1];
    self.la1 = la1;
    
    UILabel *la2 = [[UILabel alloc] init];
    la2.textColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0];
    la2.textAlignment = NSTextAlignmentLeft;
    la2.text = @"--";
    la2.font = [UIFont systemFontOfSize:10];
    [self addSubview:la2];
    self.la2 = la2;
    
    UILabel *la3 = [[UILabel alloc] init];
    la3.textColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0];
    la3.textAlignment = NSTextAlignmentCenter;
    la3.text = @"--";
    la3.font = [UIFont systemFontOfSize:10];
    [self addSubview:la3];
    self.la3 = la3;
    
    UILabel *la4 = [[UILabel alloc] init];
    la4.textColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0];
    la4.textAlignment = NSTextAlignmentCenter;
    la4.adjustsFontSizeToFitWidth = YES;
    la4.text = @"--";
    la4.font = [UIFont systemFontOfSize:10];
    [self addSubview:la4];
    self.la4 = la4;
    
    [la1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self).offset(26);
        make.width.mas_equalTo(25);
        make.top.bottom.equalTo(self);
    }];
    
    [la4 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self).offset(-15);
        make.width.mas_equalTo(50);
        make.top.bottom.equalTo(self);
    }];
    
    [la3 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(la4.mas_left).offset(-25);
        make.width.mas_equalTo(50);
        make.top.bottom.equalTo(self);
    }];
    
    [la2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(la1.mas_right).offset(31);
        make.right.equalTo(la3.mas_left).offset(-10);
        make.top.bottom.equalTo(self);
    }];

}

- (void)setModel:(YHBZDSNModel *)model{
    
    self.la1.text = model.index;
    self.la2.text = model.posSn;
    self.la4.text = [NSString stringWithFormat:@"%@元",model.backAmount];
    //2:已提交，待审核；3:审核失败；4:审核通过；5:已激活；6:已达标
    
    self.la3.textColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0];
    self.la4.textColor = BLUECOLOR;
    
    switch ([model.activeStatus intValue]) {
        case 2:

            self.la3.text = @"审核中";
            break;
        case 3:

            self.la3.text = @"审核失败";
            self.la3.textColor = UIColor.redColor;
            break;
        case 4:

            self.la3.text = @"已开通";
            break;
        case 5:

            self.la3.text = @"已激活";
            self.la4.textColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0];
            break;
        case 6:

            self.la3.text = @"已达标";
            self.la4.textColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0];
            break;
        default:
            self.la3.text = @"未开通";
            break;
    }
    
    
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
